package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.order.OrderBO;
import com.micro.modual.model.dto.order.OrderDetailDTO;
import com.micro.modual.model.dto.order.OrderListDTO;
import com.micro.modual.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>订单基础表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "订单管理",tags = "订单管理")
@RestController
@RequestMapping(value = "order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * <h2>查找订单基础表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<OrderListDTO> {@link OrderListDTO}s  订单基础表 列表返回对象
     */
    @ApiOperation(value = "查询订单基础表列表" ,notes = "查询订单基础表列表")
    @GetMapping(value = "/findOrderList")
    public RespJsonPageData<OrderListDTO> findOrderList(@RequestParam  Map<String,Object> params){
        return orderService.findList(params,OrderListDTO.class);
    }

    /**
     * <h2>根据主键编号查看订单基础表详情</h2>
     * @param id  订单基础表 主键编号
     * @return {@link OrderDetailDTO}  订单基础表 详情
     */
    @ApiOperation(value = "查询订单基础表详情",notes = "根据主键编号，查询订单基础表详情")
    @GetMapping(value = "/findOrderDetail/{id}")
    public RespJsonData<OrderDetailDTO> findOrderDetail(@PathVariable("id") Long id){
        return orderService.findDetail(id,OrderDetailDTO.class);
    }

    /**
     * <h2>新增订单基础表详情</h2>
     * @param orderBO {@link OrderBO} 订单基础表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增订单基础表",notes = "新增订单基础表")
    @PostMapping(value = "/addOrder")
    public RespJson addOrder(@RequestBody OrderBO orderBO){
        return orderService.addOrder(orderBO);
    }

    /**
     * <h2>修改订单基础表详情</h2>
     * @param orderBO  {@link OrderBO} 订单基础表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改订单基础表",notes = "修改订单基础表")
    @PostMapping(value = "/editOrder")
    public RespJson editOrder(@RequestBody OrderBO orderBO){
        return orderService.editOrder(orderBO);
    }

    /**
     * <h2>根据主键编号删除订单基础表信息</h2>
     * @param id  订单基础表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除订单基础表",notes = "根据地址ID，删除订单基础表")
    @PostMapping(value = "/deleteOrder/{id}")
    public RespJson deleteOrder(@PathVariable("id") Long id){
        return orderService.deleteOrder(id);
    }
}

